Component({
  data: {
    lastTapTime: 0,
    color: "#4D4D4D",
    selectedColor: "#E09AAC",
    selected:0,
    "list": [
      {
        "pagePath": "/pages/index/index",
        "text": "首页",
        "iconPath": "/images/tabBar/home.png",
        "selectedIconPath": "/images/tabBar/home_on.png"
      },
      {
        "pagePath": "/pages/category/index",
        "text": "分类",
        "iconPath": "/images/tabBar/cate.png",
        "selectedIconPath": "/images/tabBar/cate_on.png"
      },
      {
        "pagePath": "/pages/profile/profile",
        "text": "我的",
        "iconPath": "/images/tabBar/user.png",
        "selectedIconPath": "/images/tabBar/user_on.png"
      }
    ],
  },
  attached() {

  },
  methods: {
    onShow(){
      console.log('show')
    },
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      const currentTime = e.timeStamp; // 当前点击的时间戳
      const lastTapTime = this.data.lastTapTime; // 上一次点击的时间戳
      const timeDifference = currentTime - lastTapTime; // 时间差
      console.log(url)
      wx.switchTab({url})
      console.log(data.index,'-index')
      
      // 判断时间差是否在双击事件的时间间隔内（一般设置为300ms）
      if (timeDifference < 300 && timeDifference > 0 && data.index == 0) {
        getCurrentPages()[0].getProductList(true) // 调用双击事件处理函数
      } 
      this.setData({
        lastTapTime: currentTime
      });
    
    },

  }
})